package edu.ntu.im.p2ptrade.msg;

import edu.ntu.im.p2ptrade.P2PTrade;
import net.jxta.endpoint.Message;
import net.jxta.endpoint.StringMessageElement;

public class GenericDialog implements PMessage {
	// private Message msg;
	private String content;

	private String me;
	
	private String to;

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getMe() {
		return me;
	}

	public void setMe(String me) {
		this.me = me;
	}

	public GenericDialog(String me, String content, String to) {
		this.content = content;
		this.me = me;
		this.to = to;
	}

	public Message getMessageToTransfer() {
		Message msg = new Message();
		msg.addMessageElement(P2PTrade.getInstance().getAppName(),
				new StringMessageElement(CONTENT, content, null));
		msg.addMessageElement(P2PTrade.getInstance().getAppName(),
				new StringMessageElement(TYPE, GenericDialog.class
						.getSimpleName(), null));
		msg.addMessageElement(P2PTrade.getInstance().getAppName(),
				new StringMessageElement(PEER, me, null));
		return msg;
	}

	public String toLogMessage() {
		
		return "dialog from ["+me +"] to ["+to+"] content:["+this.content+"]";
	}

}
